/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */
package com.sofa.shark.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.sofa.shark.admin.entity.FaceImages;
import com.sofa.shark.admin.service.FaceImagesService;
import com.sofa.shark.common.core.utils.R;
import com.sofa.shark.common.log.apm.annotation.SysLog;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 人脸图片表
 *
 * @author tonypy
 * @date 2020-04-01 14:49:30
 */
@RestController
@AllArgsConstructor
@RequestMapping("/faceimages")
public class FaceImagesController {

  private final FaceImagesService faceImagesService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param faceImages 人脸图片表
   * @return
   */
  @GetMapping("/page" )
  public R getFaceImagesPage(Page page, FaceImages faceImages) {
    return R.ok(faceImagesService.page(page, Wrappers.query(faceImages)));
  }


  /**
   * 通过id查询人脸图片表
   * @param id id
   * @return R
   */
  @GetMapping("/{id}" )
  public R getById(@PathVariable("id" ) Integer id) {
    return R.ok(faceImagesService.getById(id));
  }

  /**
   * 新增人脸图片表
   * @param faceImages 人脸图片表
   * @return R
   */
  @SysLog("新增人脸图片表" )
  @PostMapping
  public R save(@RequestBody FaceImages faceImages) {
    return R.ok(faceImagesService.save(faceImages));
  }

  /**
   * 修改人脸图片表
   * @param faceImages 人脸图片表
   * @return R
   */
  @SysLog("修改人脸图片表" )
  @PutMapping
  public R updateById(@RequestBody FaceImages faceImages) {
    return R.ok(faceImagesService.updateById(faceImages));
  }

  /**
   * 通过id删除人脸图片表
   * @param id id
   * @return R
   */
  @SysLog("通过id删除人脸图片表" )
  @DeleteMapping("/{id}" )
  public R removeById(@PathVariable Integer id) {
    return R.ok(faceImagesService.removeById(id));
  }
}
